package com.yuedou.api.service.wxuser.impl;

import com.yuedou.api.dao.wxuser.UserCollectionMapper;
import com.yuedou.api.entity.wxuser.UserCollection;
import com.yuedou.api.service.base.impl.BaseServiceImpl;
import com.yuedou.api.service.wxuser.UserCollectionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Service
public class UserCollectionServiceImpl extends BaseServiceImpl<UserCollectionMapper, UserCollection> implements UserCollectionService {

    @Resource
    private UserCollectionMapper collectionMapper;

    @Override
    public long getCollectionCount(int user_id,int product_id) {

        Map<String,Object> mapCollect = new HashMap<>();
        mapCollect.put("user_id",user_id);
        mapCollect.put("product_id",product_id);
        mapCollect.put("collection_type",0);
        long count = collectionMapper.selectCountByMap(mapCollect);
        return count;
    }

    @Override
    public long getCollectionCountByMerId(int user_id, int mer_id) {
        Map<String,Object> mapCollect = new HashMap<>();
        mapCollect.put("user_id",user_id);
        mapCollect.put("mer_id",mer_id);
        mapCollect.put("collection_type",1);
        long count = collectionMapper.selectCountByMap(mapCollect);
        return count;
    }
}
